﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Batalha_Estelar
{
    public class FieldController
    {
        protected BatalhaEstelar game;
        protected GameObject Obj;

        public FieldController(BatalhaEstelar game, GameObject obj)
        {
            this.game = game;
            this.Obj = obj;
        }

        public bool Within()
        {
            return Within(Obj.Posicao);
        }

        public virtual bool Within(Vector2 newPosition)
        {
            var config = game.Config;
            var field = new Rectangle(0, 0, config.FieldWidth, config.FieldHeight);

            var rec = new Rectangle((int)newPosition.X, (int)newPosition.Y, Obj.Textura.Bounds.Width, Obj.Textura.Bounds.Height);

            return field.Contains(rec);
        }

        //if ((p.X < 0) || (p.X > config.FieldWidth - width) || (p.Y < 0) || (p.Y > config.FieldHeight - height))
        //{
        //    return false;
        //}
        //else
        //{
        //    return true;
        //}

    }
}
